#!/bin/bash
ALL=false
HELP=false
FILE=false
VERBOSE=false

echo ""
echo "\$OPTIND 被初始化的值为 $OPTIND "
echo ""
while getopts ahfvc: OPTION
do
  case $OPTION in
    a)
      ALL=true
      echo "-a used"
      echo "ALL IS $ALL"
      echo "索引值 \$OPTIND 此时为 $OPTIND"
      echo ""
      ;;
    h)
      HELP=true
      echo "-h used"
      echo "HELP is $HELP"
      echo "索引值 \$OPTIND 此时为 $OPTIND"
      echo ""
      ;;
    f)
      FILE=true
      echo "-f used"
      echo "FILE is $FILE"   
      echo "索引值 \$OPTIND 此时为 $OPTIND"
      echo ""
      ;;
    c)
      c=$OPTARG
      echo "c value is $c"
      echo "索引值 \$OPTIND 此时为 $OPTIND"
      echo ""
      ;;
    \?)
      echo "`basename $0` -[a h f v] -[c value] file"
      ;;
  esac
done
